package com.haiyangwang1.lesson12.ex2;

import java.util.Scanner;

public class Totalday {
    public void getTotalday() {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入年份:");
        int year = input.nextInt();
        System.out.println("请输入月份:");
        int month = input.nextInt();
        int totalDays = 0;
        int monthDay = 0;
        for (int i=2017; i<year; i++){
            if((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){
                totalDays += 366;
            }
            else{
                totalDays += 365;
            }
        }
        for (int i = 1; i <= month; i++) {
            switch (i) {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    monthDay = 31;
                    break;
                case 2:
                    if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
                        monthDay = 29;
                    } else {
                        monthDay = 28;
                    }
                    break;
                default:
                    monthDay = 30;
            }

            if (i < month) {
                totalDays += monthDay;
            }

        }
    }
}
